********************************************************************************
********************************************************************************
**
*REPLICATION MATERIAL FOR 
*Bräuninger, T., Däubler, T., Huber, R., & Rudolph, L. 
*How Open Lists Undermine the Electoral Support of Cohesive Parties
*forthcoming in British Journal of Political Science
*
*Version 1.0, written 2021-05-06 by Lukas Rudolph - contact: lukas.rudolph@gsi.uni-muenchen.de
********************************************************************************
********************************************************************************
**

********************************************************************************
********************************************************************************
**
/*
Datasets used:
data.dta, ESS8.dta, ESS8csDE.dta

Datasources: 
data.dta: Original survey data compiled for this project
ESS8.dta and ESS8csDE.dta: European Social Survey round 8, German respondents, general (ESS8.dta) and German specific dataset (Ess8csDE.dta).
	These datasets are not contained in this replication archive for copyright reasons. They can be retrieved from http://www.europeansocialsurvey.org/data/ after registration (we downloaded on 2020-12-04). 
	Code how these datafiles are used to create Table A2 is contained below at the end of this do-file. 

*/
********************************************************************************
********************************************************************************
**

********************************************************************************
********************************************************************************
**
/*
This Do-File replicates the results presented in:

Figure 6:	Within-respondent analysis. Share of cohesive party supporters (AfD/Greens)under closed lists (round 1) who transition to another party under open lists(round 2).

Figure A4:  Vote shares for cohesive parties under open/closed lists with/without information based on the OLS regression of Table 1 
Figure A5:  Within-respondent analysis for voters of cohesive parties (AfD, left panel; Greens, right panel) in round 1 by information treatment (no: orange dots; yes: green triangles) when voting in an open-list setting first, and in a closed-list setting second.

Table A2:   Correlations of family unification policy stance with other, more general refugee and immigration policies, and factor loadings of these issues on an "immigration policy dimension", ESS 2016 data
Table A8:   Changes in vote shares of AfD and Greens between round 1 (R1) and round 2 (R2) by treatment
*/
********************************************************************************
********************************************************************************
**

********************************************************************************
********************************************************************************
**
*prepare Stata

version 15
set more off
clear all
capture log close

/* if not already installed: install the following Stata packages in order to run this do-file: 
ssc install grstyle, replace    // grstyle Package by Ben Jann
ssc install colrspace, replace  // colrspace Package by Ben Jann
ssc install coefplot, replace   // coefplot package by Ben Jann
ssc install estout, replace     // estout package by Ben Jann
ssc install tabout, replace  // tabout package by Ian Watson
ssc install mplotoffset, replace // mplotoffset package by Nick Winter
*/
 
*if necessary, set working directory to folder containing this do-file.
*cd ""

********************************************************************************
********************************************************************************
**
*set output directories

global tab = "tables"
global fig = "figures"

********************************************************************************
********************************************************************************
**
*set colorstyle grstyle for figures
grstyle init
grstyle set plain, horizontal grid
grstyle set color Dark2 // grstyle set color mono - for greyscale

********************************************************************************
********************************************************************************
**
*load data

use data.dta, clear

********************************************************************************
********************************************************************************
**
*recode data

*********
*DVs
tab votechoiceR1, gen(choice)
foreach x in 1 2 3 4 5 6 {
rename choice`x' choice`x'1
}

tab votechoiceR2, gen(choice)
foreach x in 1 2 3 4 5 6 {
rename choice`x' choice`x'2
}

foreach x in 1 2 {
foreach z in 1 2 3 4 5 6 {
local ltest : variable label choice`z'`x'
di `"`ltest'"'

local ltest2 = substr(`"`ltest'"', 15 , .)
 di `"`ltest2'"'

label variable choice`z'`x' `"`ltest2'"'
 d choice`z'`x'
 }
 }

gen cohesive = 0 
replace cohesive = 1 if choice11 == 1 | choice51 == 1


*********
*Treatment vars
recode treatmentR1 (2 4 5 = 1 "open") (1 3 = 0 "closed"), gen(open1)
tab open1 treatmentR1

recode treatmentR2 (2 4 5 = 0 "closed") (1 3 = 1 "open"), gen(open2)
tab open2 treatmentR2

recode treatmentR1 (1 2 = 0 "noinfo") (3 4 5 = 1 "info"), gen(info1)
tab info1 treatmentR1

recode treatmentR2 (1 2 = 0 "noinfo") (3 4 5 = 1 "info"), gen(info2)
tab info2 treatmentR2


********************************************************************************
**
*FIGURES IN APPENDIX
*_______________________________________________________________________________
********************************************************************************
********************************************************************************
**

********************************************************************************
* Figure A4: Vote shares for cohesive parties under open/closed lists with/without information based on the OLS regression of Table 1 
********************************************************************************
*

reg cohesive i.open1##i.info1 if treatmentR1<=4 , r

margins info1, over(open1)
eststo: margins info1, over(open1)

mplotoffset, offset(0.25)  recast(scatter) xscale(range(-0.4 1.4)) ///
legend(order(3 "closed list" 4 "open list") row(1) pos(6) ring(0)  region(lcolor(white))) ytitle("Prediction of cohesive party vote share") ///
title( "" ) name(cohesive, replace) yscale(range(.275(0.05).425))  ylabel(.275(0.025).425) xlabel(0 "no info"  1 "with info") xtitle("")

graph export "$fig\FigA4.png", replace

********************************************************************************
* Figure A5: Within-respondent analysis for voters of cohesive parties (AfD, left panel; Greens, right panel) in round 1 by information treatment (no: orange dots; yes: green triangles) when voting in an open-list setting first, and in a closed-list setting second.
********************************************************************************
*
svyset, srs
eststo clear

eststo afd1: estpost svy: ta votechoiceR1 votechoiceR2 if treatmentR1==4 & votechoiceR2==1, col se nototal 
eststo afd2: estpost svy: ta votechoiceR1 votechoiceR2 if treatmentR1==2 & votechoiceR2==1, col se nototal 
eststo green1: estpost svy: ta votechoiceR1 votechoiceR2 if treatmentR1==4 & votechoiceR2==5, col se nototal 
eststo green2: estpost svy: ta votechoiceR1 votechoiceR2 if treatmentR1==2 & votechoiceR2==5, col se nototal 

coefplot (afd1, msymbol(triangle) ) afd2 ,  drop(AfD) bylabel("AfD vote in round 2") || green1 (green2,  ), ///
bylabel("Green vote in round 2") drop(GRUENE) se(se)  legend( order( 4 "No info treatment" 2 "Candidate info treatment" ) ///
region(lcolor(white)) row(1)   size(small)) xtitle("Proportion of other party choice in round 1") ///
order(GRUENE "DIE LINKE" SPD FDP Union AfD )  ylabel(1 "Greens" 2 "Left" 3 "SPD" 4 "FDP" 5 "CDU/CSU" 6 "AfD")

graph export "$fig\FigA5.png", replace

*_______________________________________________________________________________
********************************************************************************
********************************************************************************
**
*FIGURE IN MAIN PAPER
*_______________________________________________________________________________
********************************************************************************
********************************************************************************
**

********************************************************************************
* Figure 6: Within-respondent analysis. Share of cohesive party supporters (AfD/Greens) under closed lists (round 1) who transition to another party under open lists (round 2)
********************************************************************************
*

eststo clear
eststo afd1: estpost svy: ta votechoiceR2 votechoiceR1 if treatmentR1==3 & votechoiceR1==1, col se nototal 
eststo afd2: estpost svy: ta votechoiceR2 votechoiceR1 if treatmentR1==1 & votechoiceR1==1, col se nototal 
eststo green1: estpost svy: ta votechoiceR2 votechoiceR1 if treatmentR1==3 & votechoiceR1==5, col se nototal 
eststo green2: estpost svy: ta votechoiceR2 votechoiceR1 if treatmentR1==1 & votechoiceR1==5, col se nototal 

coefplot (afd1, msymbol(triangle) ) afd2 ,  drop(AfD) bylabel("AfD vote in round 1") || green1 (green2,  ), ///
bylabel("Green vote in round 1") drop(GRUENE) se(se)  ///
legend( order( 4 "No info treatment" 2 "Candidate info treatment" ) region(lcolor(white)) row(1) pos(6)    size(small) )     ///
 xtitle("Proportion of other party choice in round 2") ///
ylabel(1 "CDU/CSU" 2 "Left" 3 "FDP" 4 "Greens" 5 "SPD" 6 "AfD") order(GRUENE "DIE LINKE" SPD FDP Union AfD )  ylabel(1 "Greens" 2 "Left" 3 "SPD" 4 "FDP" 5 "CDU/CSU" 6 "AfD")

graph export "$fig\Fig6.png", replace

*_______________________________________________________________________________
********************************************************************************
********************************************************************************
**
*TABLES IN APPENDIX
*_______________________________________________________________________________
********************************************************************************
********************************************************************************
**

********************************************************************************
* Table A8: Changes in vote shares of AfD and Greens between round 1 (R1) and round 2 (R2) by treatment
********************************************************************************
*

* Table based on descriptive data presented below; 
* shares of round 1 to round 2 transition by treatment groups and AfD/Green party choice (yes/no) in round 1 and round 2
* relevant are the column and row shares of Green/Afd party choice (choice indicator == 1)

tab choice51 choice52 if treatmentR1==1, row col
tab choice51 choice52 if treatmentR1==2, row col
tab choice51 choice52 if treatmentR1==3, row col
tab choice51 choice52 if treatmentR1==4, row col

tab choice11 choice12 if treatmentR1==1, row col
tab choice11 choice12 if treatmentR1==2, row col
tab choice11 choice12 if treatmentR1==3, row col
tab choice11 choice12 if treatmentR1==4, row col


********************************************************************************
* Table A2: Correlations of family unification policy stance with other, more general refugee and immigration policies, and factor loadings of these issues on an "immigration policy dimension", ESS 2016 data
********************************************************************************
*


**Figure A2 builds on European Socual Survey Data, Wave 8, German respondents (cross-country and country specific dataset)
**For reasons of copyright, we do not provide the ESS data as downloaded from the ESS website

*required are the cross-country dataset (ESS8.dta) and the country specific dataset (ESS8csDE.dta)
*The subsequent code merges and extracts the data used for Table A2

	/*
***
* use dataset of ESS Wave 2016
use ESS8DE.dta, clear

* Merging country specific survey questions 2016
merge 1:1 idno using ESS8csDE.dta


****** KEEP ONLY ITEMS CONCERNED WITH MIGRATION / REFUGEES ETC.
* From ESS8csDE: rfgrade, rfgwkde, rfgcmde, rfgfnde
* From ESS8DE:   gvrfgap, rfgfrpc, rfgbfml, imbgeco, imueclt, imwbcnt

keep idno rfgbfml rfgwkde rfgcmde rfgfnde gvrfgap imbgeco imueclt imwbcnt imsmetn imdfetn impcntr

* Column two and three of Table A2
* Correlate  
pwcorr rfgbfml rfgwkde rfgcmde rfgfnde gvrfgap imbgeco imueclt imwbcnt imsmetn imdfetn impcntr, star(0.00001)

eststo clear
estpost corr rfgbfml rfgwkde rfgcmde rfgfnde gvrfgap imbgeco imueclt imwbcnt imsmetn imdfetn impcntr,
esttab , cell("rho p count") label replace


* Column four of Table A2 -> factor loadings on Factor 1
factor rfgbfml rfgwkde rfgcmde rfgfnde gvrfgap imbgeco imueclt imwbcnt imdfetn impcntr, pcf mineigen(1.0)
*/


********************************************************************************
*END
********************************************************************************
